package mc

import (
	"gitee.com/dreamwood/ez-go/db/mgo"
)

const (
	ProcessTemplateEventNew           = "mes.ProcessTemplateNew"
	ProcessTemplateEventBeforeCreate  = "mes.ProcessTemplateBeforeCreate"
	ProcessTemplateEventBeforeUpdate  = "mes.ProcessTemplateBeforeUpdate"
	ProcessTemplateEventBeforeSave    = "mes.ProcessTemplateBeforeCreate mes.ProcessTemplateBeforeUpdate"
	ProcessTemplateEventAfterCreate   = "mes.ProcessTemplateAfterCreate"
	ProcessTemplateEventAfterUpdate   = "mes.ProcessTemplateAfterUpdate"
	ProcessTemplateEventAfterSave     = "mes.ProcessTemplateAfterCreate mes.ProcessTemplateAfterUpdate"
	ProcessTemplateEventDelete        = "mes.ProcessTemplateDelete"
	ProcessTemplateAccessControlEvent = "mes.ProcessTemplateAccessControl"
)

func GetProcessTemplateConfig() *mgo.DocConfig {
	return ProcessTemplate_Config
}

var ProcessTemplate_Config *mgo.DocConfig

func init() {
	ProcessTemplate_Config = NewProcessTemplateConfig()
}
func NewProcessTemplateConfig() *mgo.DocConfig {
	return &mgo.DocConfig{
		ContainerKey: "mes.ProcessTemplate",
		Fields: []string{
			"name", "processes", "checks",
		},
		RelationFields: []string{
			"processes", "checks",
		},
		RelationConfigs: map[string]*mgo.DocRelation{
			"processes": {
				Config:     GetProcessConfig,
				DocName:    "Process",
				JoinType:   "MM",
				KeyInside:  "processesIds",
				KeyOutSide: "id",
			},
			"checks": {
				Config:     GetCheckTemplateConfig,
				DocName:    "CheckTemplate",
				JoinType:   "MM",
				KeyInside:  "checksIds",
				KeyOutSide: "id",
			},
		},
		FieldFilter: map[string]*mgo.DocFieldFilter{
			"default": {
				Select: []string{},
				Omit:   []string{},
			},
		},
	}
}
